package com.lad.provider.config;

import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author luheng
 * @create 2019/6/14
 */
//@Configuration
public class WebCorsConfig extends WebMvcConfigurerAdapter {

   /* @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("http://localhost:8081")
                .allowedMethods("*")
                .allowedHeaders("*");
    }*/

    @Bean
    public TimeOutInterceptor getInterceptor() {
        return new TimeOutInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getInterceptor())
                .addPathPatterns("/**");
        super.addInterceptors(registry);
    }
}
